<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
        <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>  
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$("#updateForm").submit(function(){
			if($(":input[name=keyword]").val()==""){
				alert("제목을 입력하세요");            
				return false;
		   }else if($(":input[name=contents]").val()==""){
				alert("내용을 입력하세요");            
				return false;
		   }else if($(":input[name=category]").val() == ""){
			   alert("대분류를 선택해주세요");
			   return false;
		   }else if($(":input[name=division]").val() == ""){
			   alert("중분류를 선택해주세요");
			   return false;
		   }else if(confirm("수정된 내용을 저장하시겠습니까?") == false){
				return false;
			}else{
				alert("소중한 정보 감사합니다.");
			}
		}); // submit
		
		$("#category").change(function(){
			$.ajax({
		    	url:"${initParam.root}info/getDivisionKind.moja",
		        data:$("#updateForm").serialize(),
		        dataType:"json", 
		        success:function(jsonData){
		        	$("#division").find("option").remove().end().append("<option value=''>중분류에 입력하기</option> ");  
		            $.each(jsonData,function(key,value){               	
		            	$("#division").append("<option value='"+value.division+"'>"+value.division+"</option>");
					});   
				}
			}); // ajax
		}); // change
	});
</script>
 <style>
.gray {
   color: #e9e9e9;
   /* border: solid 1px #555; */
   background: #6e6e6e;
   background: -webkit-gradient(linear, left top, left bottom, from(#888), to(#575757));
   background: -moz-linear-gradient(top,  #888,  #575757);
   filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#888888', endColorstr='#575757');
}

</style>
<div id="mainCss">
<form id="updateForm" action="${initParam.root}info/infoUpdateResult.moja" method="post">
<font size="5px"><b>' ${requestScope.infoVO.keyword} ' 정보수정</b></font>
<br><br>
<input type = "hidden" name = "beforeKeyword" value = "${requestScope.infoVO.keyword}">
<table border="1">
<tr>
<td bgcolor="#D2D2D2" align="center"><font color="#000000"><b>제목</b></font></td>
<td colspan="3"><input size="50" type="text" name="keyword" value="${requestScope.infoVO.keyword}" ></td>
</tr>
<tr>
<td bgcolor="#D2D2D2" align="center"><font color="#000000"><b>대분류</b></font></td>
<td><select name="category" id="category">
         	<option value="${requestScope.infoVO.category}">${requestScope.infoVO.category}</option>
            	<c:forEach items="${requestScope.categoryList }" var="str">
            <option value="${str}">${str}</option>
            </c:forEach>
      </select> 
      </td>
<td bgcolor="#D2D2D2" align="center"><font color="#000000"><b>중분류</b></font></td>
<td> <select name=division id="division">
    	<option value="">----</option>
         <option selected="selected" value="${requestScope.infoVO.division}" >${requestScope.infoVO.division}</option>
      </select> 
       </td>
       </tr>
<tr>
<td bgcolor="#D2D2D2" align="center"><font color="#000000"><b>내용</b></font></td>
<td colspan="3"><textarea cols="75" rows="15" name="contents" id="contents">${requestScope.infoVO.contents} </textarea></td>
</tr>
<tr>
<td colspan="4" align="center"><input type="submit" value="정보수정" class="gray"></td>
</tr>
</table>
</form>
</div>